<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="../static/js/axios.js"></script>
    <title>登录界面</title>
    <link rel="shortcut icon" href="../static/imgs/cms.png" type="image/x-icon">
    <script src="../static/js/jQuery.js"></script>
    <link rel="stylesheet" href="../static/css/Login.css">
</head>
<body>
    <div class="login-box">
        <h1>用户登录</h1>
        <div class="input-box">
            <div class="input-text">
                <img src="../static/imgs/用户名.png" alt="">
                <label for="username"></label><input type="text" id="username" placeholder="用户id/邮箱">
            </div>
            <div class="input-text">
                <img src="../static/imgs/密码.png" alt="">
                <label for="password"></label><input type="password" id="password" placeholder="密码">
            </div>
            <div class="forget-box">
                <a href='javascript:void(0)' class="manager_login">管理员登录</a>
                <a href="#" class="forget-btn">忘记密码?</a>
            </div>
           <div class="input-btn" id="btn001">
               登录
           </div>
            <div class="sign-up">
                还没账户？<a href="Register.html" >立即注册</a>
            </div>
        </div>
    </div>
<script>
    window.onload=function () {
        const btn1obj = document.getElementById("btn001");
        btn1obj.onclick=function () {
            submit_login();
        }
    }
     function submit_login() {
         let url='http://localhost:8080/userServlet?action=login_check'
         axios({
             method:'GET',
             url:url,
             params:{
                 username:document.getElementById("username").value,
                 password:document.getElementById("password").value
             },
         }).then(function (response) {
             console.log(response);
             alert(response.data.message);
             if(response.data.code===200)
             {   let data=response.data.data;
                 window.localStorage.setItem("email",data['username']);
                 location.href="Home.html";
             }
         })
     }
     /*忘记密码*/
     $(".forget-btn").click(function () {
         location.href="ForgetPwdPage.html";
     })
     /*管理员登录*/
     $(".manager_login").click(function () {
         location.href="ManagerLogin.html";
     })
</script>

</body>
</html>